<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>添加证件</title>
	<link rel="stylesheet" href="../../../css/aui.css" />
	<link rel="stylesheet" href="../../../css/iconfont/iconfont.css" />
	<link rel="stylesheet" href="../../../css/my/frequenter/add_certificate.css">
	<link type="stylesheet" src="../../../script/extend/parsley/src/parsley.css">
</head>

<body style="cursor: pointer;">
	<ul class="aui-list aui-form-list" style="position:static;">
		<form id="myform" data-parsley-trigger="blur" role="form" action="#" method="POST" data-parsley-validate>
			<li class="aui-list-item ">
				<div class="aui-list-item-inner">
					<div class="aui-text font-size-7 grey-8">证件类型</div>
					<div class="aui-list-item-input aui-list-item-arrow">
						<select name="card_type" id="card_type" data-parsley-required="true" data-parsley-errors-container="#err" label="asset-selection">
						<option value="1">二代身份证</option>
						<option value="2">护照</option>
						<option value="3">军人证</option>
						<option value="4">回乡证</option>
						<option value="5">港澳通行证</option>
						<option value="6">台胞证</option>
						<option value="7">其他</option>
						<option value="9">一代身份证</option>
						<option value="10">学生证</option>
					</select>
					</div>

				</div>
			</li>
			<li>
				<span id="err" style="color:#FF0000;text-indent:1em"></span>
			</li>
			<li class="aui-list-item ">
				<div class="aui-list-item-inner">
					<div class="aui-text font-size-7 grey-8">证件号码</div>
					<div class="aui-list-item-input aui-list-item-arrow">
						<input class="font-size-7" type="text" id="papers" placeholder="请输入正确的证件号码" data-parsley-required="true" data-parsley-errors-container="#err1">
					</div>
				</div>
			</li>
			<!-- <li>
			<span id="err1" style="color:#FF0000;text-indent:1em"></span>
		</li> -->
			<div class="aui-btn aui-btn-success aui-btn-block aui-btn-sm submit" style="margin:1.5rem auto;width:50%;background:#3cb0d6;" onclick="add_papers()">完成</div>
		</form>
	</ul>

</body>

</html>
<script type="text/javascript" src="../../../script/aui/api.js"></script>
<script type="text/javascript" src="../../../script/aui/aui-dialog.js"></script>
<script type="text/javascript" src="../../../script/extend/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../../script/extend/parsley/dist/parsley.remote.min.js"></script>
<script type="text/javascript" src="../../../script/extend/parsley/src/i18n/zh_cn.js"></script>
<script type="text/javascript" src="../../../script/aui/aui-toast.js"></script>
<script type="text/javascript" src="../../../script/common.js"></script>
<script type="text/javascript">
	apiready = function() {
		api.parseTapmode();
	};
	//完成
	var toast = new auiToast();
	function add_papers() {
		if (!$('#myform').parsley().validate()) {
			return false;
		}

		var papers = $("#papers").val();
		var card_type = $("#card_type").val();

		if (card_type == '1') {
			//验证身份证号码
			var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
			if (reg.test(papers) === false) {
				toast.fail({
					title: '请填写正确的证件号码',
					duration: 2000,
				});
				return false;
			}
		} else {
			var reg = /^[A-Za-z0-9]*$/;
			if (reg.test(papers) === false) {
				var toast = new auiToast();
				toast.fail({
					title: '请填写正确的证件号码',
					duration: 2000,
				});
				return false;
			}
		}

		setTimeout(function() {
			document.cookie = "papers=" + papers;
			document.cookie = "card_type=" + card_type;
			api.sendEvent({
				name: 'addCard',
				extra: {
					card_type: card_type,
					card_number: papers
				}
			});
			api.closeWin({});
		}, 1000);

	}
</script>
